package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.company.CompanyDao;
import com.itheima.domain.company.Company;
import com.itheima.service.company.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private CompanyDao companyDao;

    public List<Company> findAll() {
        return companyDao.findAll();
    }

    public Company findById(String id) {
        return companyDao.findById(id);
    }

    public void save(Company company) {
        companyDao.save(company);
    }

    public void update(Company company) {
        companyDao.update(company);
    }

    public void delete(String id) {
        companyDao.delete(id);
    }

    public PageInfo<Company> findByPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Company> list = companyDao.findAll();
        return new PageInfo<Company>(list,5);
    }

    /*public PageBean findByPage(Integer pageNum, Integer pageSize) {
        List<Company> list = companyDao.findByPage((pageNum - 1)*pageSize, pageSize);
        long total = companyDao.findCount();
        return new PageBean(pageNum,pageSize,list,total);
    }*/
}
